﻿CREATE PROCEDURE [sp_ssiscatalog].[configure]
		@collect_usage_stats		BIT				=	NULL
,		@show_docs					BIT				=	1
,		@show_docs_only				BIT				=	0
AS
BEGIN
		SET NOCOUNT ON;
		DECLARE	@vDocs	NVARCHAR(MAX)	=	N'Parameters:
@collect_usage_stats			BIT			=	NULL		/*Toggle the collection of usage stats*/
';
		EXEC	[sp_ssiscatalog].[show_docs]
					@docs			=	@vDocs
				,	@action			=	N'configure'
				,	@show_docs		=	@show_docs;
		IF (@show_docs_only = 1)
				RETURN;
		
		IF EXISTS (SELECT * FROM [sp_ssiscatalog].[configuration])
		BEGIN
				UPDATE	[sp_ssiscatalog].[configuration]
				SET		[collect_usage_stats] = ISNULL(@collect_usage_stats,[collect_usage_stats])
				;
		END
		ELSE
		BEGIN
				INSERT	[sp_ssiscatalog].[configuration]([collect_usage_stats])
				SELECT	[collect_usage_stats]	=	@collect_usage_stats
				;
		END
END